$(function(){
	/**查看*/
	$('#detail').click(function(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			var url = 'schoolEnterpriseCooperation/detail.shtml?id=' + row.id;
			showEasyUiWindow('contentFrame', url, 'win', '查看校企合作情况详情', 825, 295);
		} else {
			$.messager.alert('warning', '请选择一条数据！', 'warning');
		}
	});
	
	/** 新增 */
	$('#add').click(function(){
		var _url = 'schoolEnterpriseCooperation/add.shtml';
		/*var _parentId = _node.parentId;*/
		/*if (null != _parentId) {
			_url = _url + '?projectIndexId=' + _node.id;
		}*/
		showEasyUiWindow('contentFrame', _url, 'win', '新增校企合作情况', 825, 295);
	});
	
	/*** 编辑 */
	$('#edit').click(function(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			var url = 'schoolEnterpriseCooperation/edit.shtml?id=' + row.id;
			showEasyUiWindow('contentFrame', url, 'win', '编辑校企合作情况', 825, 295);
		} else {
			$.messager.alert('warning', '请选择一条数据！', 'warning');
		}
	});
	
	/*** 删除 */
	$('#remove').click(function(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			$.messager.confirm('确认', '你确认要删除此条数据吗?', function(r) {
				if (r) {
					var id = row.id;				
					$.get('schoolEnterpriseCooperation/delete.html', {id : id}, function(rs) {
						if (rs.success == true) {
							reSearch();
							$.messager.alert('warning', rs.message, 'warning');
						} else {
							$.messager.alert('warning', rs.message, 'warning');
						}
					});
				}
			});
		} else {
			$.messager.alert('warning', '请选择一条数据！', 'warning');
		}
	});
});

/**
 * 重载
 */
function reSearch() {
	$('#year').val('');
	doSearch();
}

/**
 * 搜索
 */
function doSearch() {
	$('#dg').datagrid('reload', {
		year : $('#year').val()
	});
}
